trigger SPA_ApprovalProcess on SPA__c (after update)
{
    //Retrieve approvers Ids i.e. memebers of SPA Approval Queue
    list<string> idList = new list<string>();    
    List<String> mailToAddresses = new List<String>();    
    group g = [SELECT (select userOrGroupId from groupMembers) 
                FROM group 
                WHERE name= 'CCP- NAM - SPA Approvers']; 
    
    for (GroupMember gm : g.groupMembers) {        
        idList.add(gm.userOrGroupId);    
    } 
    
    //Submit records for approval
    for(SPA__c sp: Trigger.new)  
    {    
        if (sp.submit_for_approval__c
            && sp.status__c<>'Approved'
            && sp.status__c <>'Submitted'
             && sp.line_item_count__c >0 ) {
            approval.ProcessSubmitRequest req1 = new Approval.ProcessSubmitRequest();
            req1.setComments('Submitting SPA request for approval.');   
            req1.setObjectId(sp.id);  
            //req1.setNextApproverIds(idList);
            //req1.setNextApproverIds='005Q0000000IFNf'; 
            approval.ProcessResult result = Approval.process(req1);    
            System.assert(result.isSuccess()); 
            System.assertEquals('Pending', result.getInstanceStatus(), 'Instance Status'+result.getInstanceStatus());
        }
    }
}